package cn.edu.zafu.bigdata.llc;

public class StaticDemo {// 静态变量，用于计数类的实例创建次数
        static int count ;
        // 实例变量，用于存储每个实例的唯一编号
        int id;

// 静态初始化块
static {
        System.out.println("Static block executed");
        count = 0;
        }

        // 实例初始化块
        {
        System.out.println("Instance block executed");
        id = count;
        count++;
        }

// 构造函数
public StaticDemo() {
        System.out.println("Constructor executed for ID: " + id);
        }

// 静态方法，用于打印当前创建了多少个实例
public static void displayCount() {
        System.out.println("Total instances created: " + count);
        }
        }
